package com.yanqu.road.server.cmd.newmonopolymkt;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.systemgroup.newmonopolymarket.NewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_NEW_MONOPOLY_MARKET_GET_USER_RANK_LIST, desc = "获取个人榜")
public class NewMonopolyMarketUserRankCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        if(!NewMonopolyMarketMgr.canEnterSystem(player)){
            ret = GameErrorCode.E_SYSTEM_NO_OPEN;
            return;
        }

        NewMonopolyMarketMgr.sendAppointActivityPacket(player.getUserId(), Protocol.C_NEW_MONOPOLY_MARKET_GET_USER_RANK_LIST,
                NewMonopolyMarketProto.NewMonopolyMarketUserRankListReqMsg.newBuilder());

    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_NEW_MONOPOLY_MARKET_GET_USER_RANK_LIST, NewMonopolyMarketProto.NewMonopolyMarketUserRankListRespMsg.newBuilder().setRank(RankProto.RankListMsg.newBuilder()));
        }
    }
}
